/*!
 * # 参数列表实体类:
 *  SearchPostUsers - 搜索岗位用户
 * 
 * # 描述:
 *  按用户名、登录名、编号、手机或邮件搜索用户列表。
 *  
 *  Copyright (c), 上海沃恩信息科技有限公司.
 *  All rights reserved.
 *  Licensed under BSD (https://www.pittypat.work/bsd.html).
 */

using Pittypat;

namespace Waln.Authority.Organization.Args
{
	/// <summary>
	/// 功能 搜索岗位用户 的参数列表。
	/// </summary>
	[global::Pittypat.Function(Transaction = false)]
	public sealed class SearchPostUsers : global::Pittypat.FunctionArgs
	{
		#region 构造函数

		/// <summary>
		/// 初始化 SearchPostUsers 类的一个新实例。
		/// </summary>
		public SearchPostUsers()
		{
			// 页码
			this.PageIndex = null;
			// 页面尺寸
			this.PageSize = null;
			// 总行数
			this.TotalRows = null;
			// 排序名称
			this.OrderName = null;
			// 排序方向
			this.OrderDirection = null;
			// 关键词
			this.Keyword = null;
			// 工作岗位的 Id
			this.PostId = null;
			// 用户列表
			this.Users = null;
		}

		#endregion

		#region 属性

		/// <summary>
		/// 获取或者设置页码。
		/// </summary>
		[global::Pittypat.Parameter(0, Role = global::Pittypat.ParameterRole.PageIndex)]
		public @int64? PageIndex { get; set; }

		/// <summary>
		/// 获取或者设置页面尺寸。
		/// </summary>
		[global::Pittypat.Parameter(1, Role = global::Pittypat.ParameterRole.PageSize)]
		public @int64? PageSize { get; set; }

		/// <summary>
		/// 获取或者设置总行数。
		/// </summary>
		[global::Pittypat.Parameter(2, Direction = global::Pittypat.ParameterDirection.Out, Role = global::Pittypat.ParameterRole.TotalRows)]
		public @int64? TotalRows { get; set; }

		/// <summary>
		/// 获取或者设置排序名称。
		/// </summary>
		[global::Pittypat.Parameter(3, Role = global::Pittypat.ParameterRole.OrderName, MaxLength = 30)]
		public @string? OrderName { get; set; }

		/// <summary>
		/// 获取或者设置排序方向。
		/// </summary>
		[global::Pittypat.Parameter(4, Role = global::Pittypat.ParameterRole.OrderDirection, MaxLength = 4)]
		public @string? OrderDirection { get; set; }

		/// <summary>
		/// 获取或者设置关键词。
		/// </summary>
		/// <remarks>
		/// 搜索关键词。
		/// </remarks>
		[global::Pittypat.Parameter(5, MaxLength = 50)]
		public @string? Keyword { get; set; }

		/// <summary>
		/// 获取或者设置工作岗位的 Id。
		/// </summary>
		/// <remarks>
		/// 目标工作岗位的 Id。
		/// </remarks>
		[global::Pittypat.Parameter(6)]
		public @uuid? PostId { get; set; }

		/// <summary>
		/// 获取或者设置用户列表。
		/// </summary>
		/// <remarks>
		/// 满足条件的用户列表。
		/// </remarks>
		[global::Pittypat.Parameter(7, Direction = global::Pittypat.ParameterDirection.Out)]
		public global::Pittypat.DataList<global::Waln.Authority.Organization.Data.User> Users { get; set; }

		/// <summary>
		/// 获取或者设置指定名称的参数值。
		/// </summary>
		/// <param name="name">参数名称，不区分大小写。</param>
		/// <returns>目标名称的参数值。如果参数不存在，则返回 null。</returns>
		/// <exception cref="global::System.ArgumentException">设置参数值时发现参数不存在。</exception>
		public override object this[string name]
		{
			get
			{
				if (string.IsNullOrEmpty(name))
				{
					return null;
				}

				switch (name.ToLower())
				{
					case "pageindex":
						return this.PageIndex;
					case "pagesize":
						return this.PageSize;
					case "totalrows":
						return this.TotalRows;
					case "ordername":
						return this.OrderName;
					case "orderdirection":
						return this.OrderDirection;
					case "keyword":
						return this.Keyword;
					case "postid":
						return this.PostId;
					case "users":
						return this.Users;
					default:
						return null;
				}
			}
			set
			{
				if (string.IsNullOrEmpty(name))
				{
					throw new global::System.ArgumentException("没有提供有效的参数名称。", "name");
				}

				switch (name.ToLower())
				{
					case "pageindex":
						this.PageIndex = (@int64?)value;
						break;
					case "pagesize":
						this.PageSize = (@int64?)value;
						break;
					case "totalrows":
						this.TotalRows = (@int64?)value;
						break;
					case "ordername":
						this.OrderName = (@string?)value;
						break;
					case "orderdirection":
						this.OrderDirection = (@string?)value;
						break;
					case "keyword":
						this.Keyword = (@string?)value;
						break;
					case "postid":
						this.PostId = (@uuid?)value;
						break;
					case "users":
						this.Users = (global::Pittypat.DataList<global::Waln.Authority.Organization.Data.User>)value;
						break;
					default:
						throw new global::System.ArgumentException(name + " 不是 " + this.GetType().Name + " 的有效参数名称。", "name");
				}
			}
		}

		#endregion

		#region 方法

		/// <summary>
		/// 将当前对象作为 JSON 字符串写入指定的文本流。
		/// </summary>
		/// <param name="writer">目标文本流。</param>
		/// <exception cref="global::System.ArgumentNullException">writer 是 null。</exception>
		public override void Write(global::System.IO.TextWriter writer)
		{
			if (writer == null)
			{
				throw new global::System.ArgumentNullException("writer");
			}

			writer.Write('{');

			// 页码
			writer.Write("\"pageIndex\":");
			this.PageIndex.Write(writer);
			writer.Write(',');

			// 页面尺寸
			writer.Write("\"pageSize\":");
			this.PageSize.Write(writer);
			writer.Write(',');

			// 总行数
			writer.Write("\"totalRows\":");
			this.TotalRows.Write(writer);
			writer.Write(',');

			// 排序名称
			writer.Write("\"orderName\":");
			this.OrderName.Write(writer);
			writer.Write(',');

			// 排序方向
			writer.Write("\"orderDirection\":");
			this.OrderDirection.Write(writer);
			writer.Write(',');

			// 关键词
			writer.Write("\"keyword\":");
			this.Keyword.Write(writer);
			writer.Write(',');

			// 工作岗位的 Id
			writer.Write("\"postId\":");
			this.PostId.Write(writer);
			writer.Write(',');

			// 用户列表
			writer.Write("\"users\":");
			if (this.Users == null)
			{
				writer.Write("null");
			}
			else
			{
				this.Users.Write(writer);
			}

			writer.Write('}');
		}

		#endregion
	}
}
